﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XProject.DataVisit.Model.Role;
using NHibernate;
using NHibernate.Criterion;

namespace XProject.DataVisit.DAL.BaseManager
{
    public class DMenu:AbstractSupportDal<GYMenu>
    {
        public IList<GYMenu> GetParentList()
        {
            IList<GYMenu> t = new List<GYMenu>();
            Template.Execute(delegate(ISession session)
            {
                t = session.CreateCriteria<GYMenu>()
                    .Add(Expression.IsNull("ParentID"))
                    .AddOrder(Order.Asc("OrderID"))
                    .List<GYMenu>();
                return t;
            });
            return t;
        }

        public IList<GYMenu> GetListByKey(Guid id)
        {
            IList<GYMenu> t = new List<GYMenu>();
            Template.Execute(delegate(ISession session)
            {
                t = session.CreateCriteria<GYMenu>()
                    .Add(Expression.Eq("ParentID", id))
                    .AddOrder(Order.Asc("OrderID"))
                    .List<GYMenu>();
                return t;
            });
            return t;
        }
    }
}
